require_relative 'xml_helpers'

module CSDNConfig
	module Triggers

    module TriggerSchedules
			def frequently
				new 'H/15 * * * 1-5'
			end
			def hourly
				new '@hourly'
			end
			def daily
				new '@daily'
			end
    end
    
		class SCM < Struct.new(:schedule)
			
			include XMLHelpers
      extend TriggerSchedules

			def to_xml
				apply_template <<XML_CONFIG
    <hudson.triggers.SCMTrigger>
      <spec><%= schedule %></spec>
      <ignorePostCommitHooks>false</ignorePostCommitHooks>
    </hudson.triggers.SCMTrigger>
XML_CONFIG
			end

		end

		class Timer < Struct.new(:schedule)
			
			include XMLHelpers
      extend TriggerSchedules

			def to_xml
				apply_template <<XML_CONFIG
    <hudson.triggers.TimerTrigger>
      <spec><%= schedule %></spec>
    </hudson.triggers.TimerTrigger>
XML_CONFIG
			end

		end

	end
end

